package net.csdn.business.mirror.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.domain.PageDto;
import net.csdn.business.common.domain.mirror.AddMirrorImportDataDTO;
import net.csdn.business.common.domain.mirror.ImportRetryDTO;
import net.csdn.business.common.domain.mirror.ProjectMirrorDataQueryDto;
import net.csdn.business.common.domain.query.mirror.MirrorConfigQuery;
import net.csdn.business.common.domain.query.mirror.MirrorPageQuery;
import net.csdn.business.common.domain.query.mirror.TokenConfigQuery;
import net.csdn.business.common.domain.request.mirror.*;
import net.csdn.business.common.domain.vo.mirror.MirrorConfigVO;
import net.csdn.business.common.domain.vo.mirror.MirrorNameSpaceVO;
import net.csdn.business.common.domain.vo.mirror.MirrorProjectPageVO;
import net.csdn.business.common.domain.vo.mirror.ProjectMirrorDataVO;
import net.csdn.business.mirror.entity.bean.ProjectMirrorData;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface ProjectMirrorDataService {

    ProjectMirrorData getById(Long id);

    ProjectMirrorData getByFullPath(String fullPath);

    List<ProjectMirrorData> getByFullPaths(List<String> fullPaths);

    void updateAllStatus(ProjectMirrorData data, Integer status);

    void updateAllStatus(Long id, Integer status);

    public Integer deleteMirror(MirrorDelDTO params) throws Exception ;

    void retry(MirrorRetyDTO params) throws Exception;

    PageDto<ProjectMirrorData> searchData(ProjectMirrorDataQueryDto dto);

    Page<ProjectMirrorDataVO> listPageMirror(MirrorPageQuery query);

    void updateMirrorData(Long id, Integer status, Date nextExecutionAt,Date lastExecutionAt, String error);

    void updateSyncMirrorData(Long id, Integer status, Date nextExecutionAt, String error);

    void batchInsert(AddMirrorImportDataDTO dto);

    void batchInsert(String creator, String creatorId, String token, int userType, int type,int isSync, List<AddMirrorImportDataDTO.Info> imports);

    void startImport(AddMirrorImportDataDTO dto);

    long mirrorImportSize();

    void importSuccess(ProjectMirrorData data, Long projectId);

    void importFailed(ProjectMirrorData data, Long projectId);

    void mirrorSuccess(ProjectMirrorData data);

    void mirrorFailed(ProjectMirrorData data);

    Map<String, ProjectMirrorData> getByCreatorAndRepoPaths(String username, List<String> fullPaths);

    public Map<String, ProjectMirrorData> getMirrorByRepoPaths(Integer type,String creatorId,List<String> fullPaths);

    Integer delete(ProjectMirrorData data);



    /**
     * 根据用户id获取仓库镜像的配置信息
     * @param query
     * @return
     */
    public MirrorConfigVO getTokenConfig(TokenConfigQuery query);


    /**
     * 根据用户id获取仓库镜像的配置信息
     * @param query
     * @return
     */
    public MirrorConfigVO getConfig(MirrorConfigQuery query);

    /**
    * @Description: 更新用户镜像配置
    * @Param:
    * @return:
    * @Author: zhangyl
    * @Date: 2024/7/18
    */
    public void updateTokenConfig(TokenConfigDTO params) throws Exception ;



    /**
     * @Description: 更新用户镜像配置
     * @Param:
     * @return:
     * @Author: zhangyl
     * @Date: 2024/7/18
     */
    public void updateConfig(MirroConfigDTO params) throws Exception ;



    /** 
    * @Description: 查询用户镜像仓库列表
    * @Param: 
    * @return: 
    * @Author: zhangyl
    * @Date: 2024/7/19
    */
    public MirrorProjectPageVO getRepoList(MirrorConfigQuery query)  throws Exception;


    /**
    * @Description: 前台用户获取源在github或者gittee的全部命名空间
    * @Param:
    * @return:
    * @Author: zhangyl
    * @Date: 2024/7/19
    */
    public List<MirrorNameSpaceVO> getNamespace(MirrorConfigQuery query) throws Exception;


    public Integer changeMirrorSyncStatus(MirrorSyncStatusDTO params) throws Exception;


    /**
     * 前台用户,导入失败的时候，重试导入镜像仓库
     */
    public void importProjectRetry(ImportRetryDTO params);

}